<template>
  <div class="view-css">
    <div class="content-css">
      <div class="title-css">
        <h1>XXXX</h1>
        <h1>XXXX</h1>
      </div>
      <el-form :model="ruleForm" :rules="rules" ref="ruleForm" class="login-form">
        <!-- <el-form-item> -->
        <h2 class="form-title">用户登录</h2>
        <!-- </el-form-item> -->
        <el-form-item prop="username">
          <el-input v-model="ruleForm.username" prefix-icon="el-icon-user"></el-input>
        </el-form-item>
        <el-form-item prop="password">
          <el-input type="password" v-model="ruleForm.password" prefix-icon="el-icon-unlock"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button class="w-100" type="primary" @click="submitForm('ruleForm')">登录</el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<script>
import {
  asyncRouterMap
} from '../../router/lisyCopy'
export default {
  data() {
    return {
      ruleForm: {
        username: "admin",
        password: "123456"
      },
      rules: {
        username: [
          { required: true, message: "请输入用户名", trigger: "blur" }
        ],
        password: [{ required: true, message: "请输入密码", trigger: "blur" }]
      }
    };
  },
  created () {
    // console.log(asyncRouterMap);
  },
  methods: {
    // 登录请求
    submitForm(formName) {
      this.$refs[formName].validate(valid => {
        if (valid) {
          // this.$api.INDEX.LOGIN(this.ruleForm)
          //   .then(res => {
            // 
            this.$store.commit('ChangeState', 1)
              sessionStorage.setItem("permissionId", 1);
              sessionStorage.setItem("UserInfo", JSON.stringify({userName:'超级管理员'}));
              // sessionStorage.setItem("companyId", res.data.cid);
              sessionStorage.setItem("companyId",1);
              sessionStorage.setItem("RouterList", JSON.stringify(asyncRouterMap));
              this.$router.push({ path: "/Home" });
            // })
            // .catch(() => {
            //   this.$message({
            //     message: "用户名或密码错误",
            //     type: "error"
            //   });
            // });
        } else {
          return false;
        }
      });
    }
  }
};
</script>

<style scoped lang="scss">
@import "../../style/OverAll.scss";
.view-css {
  @extend .font-cor-fff;
  .content-css {
    .title-css {
      margin-top: -300px;
    }
  }
  display: flex;
  justify-content: $font-c;
  align-items: $font-c;
  text-align: $font-c;
  background: url("../../assets/image/a (1).jpg") no-repeat 100% 100%;
  letter-spacing: 6px;
  h1 {
    font-size: 40px;
  }
  .login-form {
    width: 340px;
    margin: 0 auto;
    .form-title {
      padding: 60px 0 10px 0;
      font-size: 40px;
      font-weight: 400;
    }
    /deep/ .el-input__inner {
      border: 1px solid #ffffff;
      background: none;
      color: #fff;
      @extend .font-cor-fff;
    }
    /deep/ .el-input__icon {
      @extend .font-cor-fff;
      font-size: 22px;
    }
  }
}
</style>